package org.zhzh.crawler.service;

import javax.transaction.Transactional;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.zhzh.crawler.dao.BTHeavenDao;
import org.zhzh.crawler.model.BTHeavenModel;

@Service
@Transactional
public class BTHeavenServiceImpl implements BTHeavenService {

	@Autowired
	private BTHeavenDao btHeavenDao;

	@Override
	public boolean insertBTHeaven(BTHeavenModel model) {
		if (model == null) {
			return false;
		}
		return btHeavenDao.save(model) != null;
	}

	@Override
	public boolean isExist(String name) {
		if (StringUtils.isBlank(name)) {
			return false;
		}
		int count = btHeavenDao.countByUniqueName(name);
		return count > 0 ? true : false;
	}

}
